package com.example.demo.arithmetic.algorithm.dynamic_programing;

import java.util.Arrays;
import java.util.Comparator;
import java.util.stream.Stream;

/**
 * 最长递增子序列
 */

/*
1   3   6   4   9
1   13  16  14  19
        136 134 139
                169
                1369
                149
                1349



 */
public class Leetcode300 {
    public static void main(String[] args) {
        System.out.println(new Leetcode300().lengthOfLIS(new int[]{1, 3, 6, 4, 9}));
    }


    public int lengthOfLIS(int[] nums) {
        int[] dp = new int[nums.length];
        Arrays.fill(dp, 1);
        for (int i = 1; i < nums.length; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {//满足了升序条件
                    dp[i] = Integer.max(dp[i], dp[j] + 1);
                }
            }
            System.out.println(Arrays.toString(dp));
        }
        return Arrays.stream(dp).max().getAsInt();
    }
}
